package com.yztc.orangeentertainment.ui.main.findfragment.findpersenter;

import com.yztc.orangeentertainment.bean.findbean.HotSearchStarDataBean;
import com.yztc.orangeentertainment.config.FindUrlConfig;
import com.yztc.orangeentertainment.config.SubscribeUrlConfig;
import com.yztc.orangeentertainment.ui.main.findfragment.findmodel.ISearchStarModle;
import com.yztc.orangeentertainment.ui.main.findfragment.findmodel.OnLoadSearchStarListener;
import com.yztc.orangeentertainment.ui.main.findfragment.findmodel.SearchStarModle;
import com.yztc.orangeentertainment.ui.main.findfragment.findview.ISearchStarView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by My on 2016/10/9.
 */
public class SearchStarPresenter {
    private ISearchStarModle modle;
    private ISearchStarView view;

    public SearchStarPresenter(ISearchStarView view) {
        this.view = view;
        this.modle = new SearchStarModle();
    }

    public void getSearchStarListFromNet(String keyword) {
        Map<String, String> map = new HashMap<>();
        map.put(FindUrlConfig.FindParams.KEYWORD, keyword);
        map.put(FindUrlConfig.FindParams.PAGE, FindUrlConfig.FindDefaultVaule.PAGE_VALUE);
        map.put(FindUrlConfig.FindParams.SIZE, FindUrlConfig.FindDefaultVaule.SIZE_VALUE);
        map.put(FindUrlConfig.FindParams.TS, FindUrlConfig.FindDefaultVaule.TS_VALUE);
        map.put(FindUrlConfig.FindParams.TYPE, FindUrlConfig.FindDefaultVaule.TYPE_VALUE);
        map.put(SubscribeUrlConfig.Params.MAC, SubscribeUrlConfig.All_DefaultVaule.MAC_VALUE);
        map.put(SubscribeUrlConfig.Params.UID, SubscribeUrlConfig.All_DefaultVaule.UID_VALUE);
        map.put(SubscribeUrlConfig.Params.PF, SubscribeUrlConfig.All_DefaultVaule.PF_VALUE);
        map.put(SubscribeUrlConfig.Params.NET, SubscribeUrlConfig.All_DefaultVaule.NET_VALUE);
        map.put(SubscribeUrlConfig.Params.ACCESSTOKEN, SubscribeUrlConfig.All_DefaultVaule
                .ACCESSTOKEN_VALUE);
        map.put(SubscribeUrlConfig.Params.CHANNEL, SubscribeUrlConfig.All_DefaultVaule
                .CHANNEL_VALUE);
        map.put(SubscribeUrlConfig.Params.VER, SubscribeUrlConfig.All_DefaultVaule.VER_VALUE);
        map.put(SubscribeUrlConfig.Params.RES, SubscribeUrlConfig.All_DefaultVaule.RES_VALUE);

        modle.LoadSearchStarData("article", map, new OnLoadSearchStarListener() {
            @Override
            public void getHotSearchStarListBeanList(HotSearchStarDataBean
                                                             hotSearchStarDataBean) {
                view.setSearchStarList(hotSearchStarDataBean);
            }

            @Override
            public void onFailure(Exception e) {
                view.onVerticalFail(e.getMessage());
            }
        });
    }
}
